package com.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.sentinel.common.Result;
import com.sentinel.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 谢阳
 * @version 1.0
 * @date 2023/11/17 16:03
 * @description
 */
@RestController
@RequestMapping("/order")
@RequiredArgsConstructor
public class OrderController {

    private final OrderService orderService;

    @SentinelResource("hot")
    @GetMapping("/{id}")
    public Result getOrderById(@PathVariable Long id) {
        return Result.success(id);
    }

    @GetMapping("/update")
    public Result update() {
        return Result.success();
    }

    @GetMapping("/query")
    public Result query() {
        orderService.query();
        return Result.success();
    }

    @GetMapping("/save")
    public Result save() {
        orderService.save();
        return Result.success();
    }
}
